home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / m_to_r / mailx4 / ximplevb.pa_ / ximplevb.pa
Encoding:
Text File  |  1996-09-15  |  2.8 KB  |  127 lines

  1. unit Simplevb;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Mailx, VBXCtrl, ExtCtrls;
  8.  
  9. {$I mailxdef.int}
  10.  
  11. type
  12.   TSimpleForm = class(TForm)
  13.     MForm1: TMForm;
  14.     MSess1: TMSess;
  15.     btlLogon: TButton;
  16.     MMsg1: TMMsg;
  17.     GroupBox1: TGroupBox;
  18.     Label2: TLabel;
  19.     szMsgNum: TLabel;
  20.     Bevel1: TBevel;
  21.     Label1: TLabel;
  22.     szCount: TLabel;
  23.     Label3: TLabel;
  24.     Label4: TLabel;
  25.     szSubject: TEdit;
  26.     szNoteText: TMemo;
  27.     btnFirst: TButton;
  28.     btnNext: TButton;
  29.     procedure btlLogonClick(Sender: TObject);
  30.     procedure btnFirstClick(Sender: TObject);
  31.     procedure btnNextClick(Sender: TObject);
  32.     procedure FormCreate(Sender: TObject);
  33.     procedure FormUpdate;
  34.     function  IsSessionActive:Boolean;
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40.  
  41. var
  42.   SimpleForm: TSimpleForm;
  43.  
  44. implementation
  45.  
  46. {$R *.DFM}
  47. uses MailSys;
  48.  
  49. procedure TSimpleForm.btlLogonClick(Sender: TObject);
  50. begin
  51.      MSess1.Logon:=TRUE;
  52.      if IsSessionActive=TRUE then
  53.      begin
  54.           szCount.caption:=IntToStr(MMsg1.MsgCount);
  55.           btnFirstClick(Sender);
  56.      end
  57.      else
  58.      begin
  59.           szCount.caption:='';
  60.           szSubject.Text:='';
  61.           szNoteText.Text:='';
  62.           szMsgNum.caption:='';
  63.      end;
  64. end;
  65.  
  66. procedure TSimpleForm.btnFirstClick(Sender: TObject);
  67. begin
  68.      if IsSessionActive=TRUE then
  69.      begin
  70.           MMsg1.Action:=ACTION_FINDFIRST;
  71.           FormUpdate;
  72.      end;
  73.  
  74. end;
  75.  
  76. function  TSimpleForm.IsSessionActive:Boolean;
  77. begin
  78.      if MSess1.Logon=TRUE then
  79.      begin
  80.           Result:=TRUE;
  81.      end
  82.      else
  83.      begin
  84.          Application.MessageBox('No Active Session available',
  85.                                 'Mail eXtension DEMO for DELPHI',
  86.                                 MB_ICONSTOP);
  87.          Result:=FALSE;
  88.      end;
  89. end;
  90.  
  91. procedure TSimpleForm.btnNextClick(Sender: TObject);
  92. begin
  93.      if IsSessionActive=TRUE then
  94.      begin
  95.           MMsg1.Action:=ACTION_FINDNEXT;
  96.           FormUpdate;
  97.      end;
  98.  
  99. end;
  100.  
  101. procedure TSimpleForm.FormUpdate;
  102. begin
  103.      if (MMsg1.ErrorNum<>0) then
  104.      begin
  105.           Application.MessageBox('Error Fetching Inbox message',
  106.                                  'Mail X DEMO for DELPHI',
  107.                                  MB_ICONINFORMATION);
  108.      end
  109.      else
  110.      begin
  111.           szSubject.Text:=MMsg1.Subject;
  112.           szNoteText.Text:=MMsg1.NoteText;
  113.           szMsgNum.caption:=IntToStr(MMsg1.FetchMsg);
  114.      end;
  115. end;
  116.  
  117. procedure TSimpleForm.FormCreate(Sender: TObject);
  118. var
  119.    MailSystem: TMailSystem;
  120. begin
  121.      MailSystem:=TMailSystem.Create(Self);
  122.      MailSystem.ShowModal;
  123.      MailSystem.Free;
  124. end;
  125.  
  126. end.
  127.